<?php
// src/Newsletter/NewsBundle/Entity/Newsletter.php

namespace Newsletter\NewsBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;


/**
 * @ORM\Entity(repositoryClass="Newsletter\NewsBundle\Entity\Repository\NewsletterRepository")
 * @ORM\Table(name="newsletter")
 * @ORM\HasLifecycleCallbacks()
 */
class Newsletter
{

	public function __toString()
	{
		return $this->getTitle();
	}


    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

	/**
     * @ORM\Column(type="string")
     */
    private $title;

 	/**
     * @ORM\Column(type="integer")
     */
    private $month;

 	/**
     * @ORM\Column(type="integer")
     */
    private $year;

	/**
     * @ORM\Column(type="string")
     */
    private $description;

	/**
     * @ORM\Column(type="string")
     */
    private $keywords;

 
    /**
     * @ORM\Column(type="text")
     */
    private $body_html;


    /**
     * @ORM\Column(type="text")
     */
    private $body_text;

    /**
     * @ORM\Column(type="datetime")
     */
    private $created_at;

     /**
     * @ORM\Column(type="datetime")
     */
    private $updated_at;

    /**
     * @ORM\Column(type="datetime")
     */
    private $sent_at;


    public function __construct()
    {
		// $this->comments = new ArrayCollection();

        $this->setCreated(new \DateTime());
        $this->setUpdated(new \DateTime());
    }

    /**
     * Get slug
     *
     * @return string 
     */
    public function getSlug()
    {
		 return $this->year . '-' . $this->month ;
       // return 'issue'.$this->year . '-' . $this->month.'-num'+$this->id ;
    }




	public function slugify($text)
	{
		// replace non letter or digits by -
		$text = preg_replace('#[^\\pL\d]+#u', '-', $text);

		// trim
		$text = trim($text, '-');

		// transliterate
		if (function_exists('iconv'))
		{
			$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
		}

		// lowercase
		$text = strtolower($text);

		// remove unwanted characters
		$text = preg_replace('#[^-\w]+#', '', $text);

		if (empty($text))
		{
			return 'n-a';
		}

		return $text;
	}



  

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set title
     *
     * @param string $title
     * @return Newsletter
     */
    public function setTitle($title)
    {
        $this->title = $title;
    
        return $this;
    }

    /**
     * Get title
     *
     * @return string 
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Set month
     *
     * @param integer $month
     * @return Newsletter
     */
    public function setMonth($month)
    {
        $this->month = $month;
    
        return $this;
    }

    /**
     * Get month
     *
     * @return integer 
     */
    public function getMonth()
    {
        return $this->month;
    }

    /**
     * Set year
     *
     * @param integer $year
     * @return Newsletter
     */
    public function setYear($year)
    {
        $this->year = $year;
    
        return $this;
    }

    /**
     * Get year
     *
     * @return integer 
     */
    public function getYear()
    {
        return $this->year;
    }

    /**
     * Set description
     *
     * @param string $description
     * @return Newsletter
     */
    public function setDescription($description)
    {
        $this->description = $description;
    
        return $this;
    }

    /**
     * Get description
     *
     * @return string 
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set keywords
     *
     * @param string $keywords
     * @return Newsletter
     */
    public function setKeywords($keywords)
    {
        $this->keywords = $keywords;
    
        return $this;
    }

    /**
     * Get keywords
     *
     * @return string 
     */
    public function getKeywords()
    {
        return $this->keywords;
    }

    /**
     * Set body_html
     *
     * @param string $bodyHtml
     * @return Newsletter
     */
    public function setBodyHtml($bodyHtml)
    {
        $this->body_html = $bodyHtml;
    
        return $this;
    }

    /**
     * Get body_html
     *
     * @return string 
     */
    public function getBodyHtml()
    {
        return $this->body_html;
    }

    /**
     * Set body_text
     *
     * @param string $bodyText
     * @return Newsletter
     */
    public function setBodyText($bodyText)
    {
        $this->body_text = $bodyText;
    
        return $this;
    }

    /**
     * Get body_text
     *
     * @return string 
     */
    public function getBodyText()
    {
        return $this->body_text;
    }

    /**
     * Set created_at
     *
     * @param \DateTime $createdAt
     * @return Newsletter
     */
    public function setCreatedAt($createdAt)
    {
        $this->created_at = $createdAt;
    
        return $this;
    }

    /**
     * Get created_at
     *
     * @return \DateTime 
     */
    public function getCreatedAt()
    {
        return $this->created_at;
    }

    /**
     * Set updated_at
     *
     * @param \DateTime $updatedAt
     * @return Newsletter
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updated_at = $updatedAt;
    
        return $this;
    }

    /**
     * Get updated_at
     *
     * @return \DateTime 
     */
    public function getUpdatedAt()
    {
        return $this->updated_at;
    }

    /**
     * Set sentAt
     *
     * @param \DateTime $sentAt
     * @return Newsletter
     */
    public function setSentAt($sentAt)
    {
        $this->sent_at = $sent_at;
    
        return $this;
    }

    /**
     * Get sentAt
     *
     * @return \DateTime 
     */
    public function getSentAt()
    {
        return $this->sentAt;
    }
}